/*
*
* Author: jff
*
* Date:
*
* Function:
*
*/

const path = require('path')
const webpack = require('webpack')
const htmlWebpackPlugin = require('html-webpack-plugin')
const vuePlugin = require('vue-loader/lib/plugin')
const autoprefixer = require('autoprefixer');
var px2rem = require('postcss-px2rem');

module.exports = {
    entry:path.join(__dirname, "./src/main.js"),
    output: {
        path: path.join(__dirname, "./dist"),
        filename: "bundle.js"
    },
    devServer: {
        port:3000,
        open:true,
        hot:true,
        host:'192.168.1.160'
    },
    plugins: [
        new webpack.LoaderOptionsPlugin({
             options: {
                 context: __dirname,
                 postcss: [ autoprefixer, px2rem({remUnit:75}) ]
             }
        }),
        new webpack.HotModuleReplacementPlugin (),
        new htmlWebpackPlugin({
            template: "./src/index.html",
            filename: "index.html"
        }),
        new vuePlugin()
    ],
    module: {
        rules: [
            {test:/\.css$/, use:["style-loader", "css-loader"]},
            {test: /\.scss$/, use: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader']},
            {test:/\.vue$/, use:'vue-loader'},
            {test:/\.(png|jpg|jpeg|gif)/, use:'url-loader'},
            {test: /\.(ttf|svg|eof|woff|woff2)/, use:"url-loader"},
            {test:/\.js$/, use:'babel-loader', exclude: /node_modules/}
        ],
    },
    resolve: {
        alias: {
            "vue$":'vue/dist/vue.js'
        }
    },
}
